<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    <%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<%@ page import="java.util.Map" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://"
            + request.getServerName() + (request.getServerPort() == 80? path : ":" + request.getServerPort()+path);
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>app test</title>
<link rel="stylesheet" type="text/css" href="<c:url value="jslib/easyui1.5/themes/default/easyui.css"/>"/>
<link rel="stylesheet" type="text/css" href="<c:url value="jslib/easyui1.5/themes/icon.css" />"/>
</head>
<body>
APP产品区分：
<select id="appDiv" class="easyui-combobox" name="appDiv">
    <option value="">-=选择APP产品区分=-</option>
    <option value="0">云平台App测试</option>
    <%--<option  value="1">保安公司报警</option>
    <option  value="2">视频连通</option>--%>
</select>
<select id="methodOperate" name="methodOperate" class="easyui-combobox" style="width:280px;">
</select>
<br/>
<hr/>
API 请 求 URL：
<input type="text" id="reqUrl" style="width:500px;"  >
<br/>
Method Name：
<input type="text" id="reqmethod" style="width:300px;" readonly="readonly">
<br/>
Request Body(json格式):<br/>
<textarea id="txtrequestbody" width="800px" rows="15" cols="100" ></textarea>
<br/>
<a href="#" class="sendApiRequest easyui-linkbutton">发送请求</a>
<br/>
<div id = 'fileDiv' style="display:none">
<form id="fileForm" method="post" enctype="multipart/form-data">
<span>File1</span>
<input type="file" id="file1" name="file" size="10" onchange="setFiles(this)"/>
<br/>
<span>File2</span>
<input type="file" id="file2" name="file" size="10" onchange="setFiles(this)"/>
<br/>
<span>File3</span>
<input type="file" id="file3" name="file" size="10" onchange="setFiles(this)"/>
<br/>
</form>
<div id="uploadProgress" class="easyui-progressbar" style="width:400px;"></div>
</div>
Response Body(json格式):<br/>
<textarea id="txtresponsebody" width="800px" rows="30" cols="100" ></textarea>
<br/>

ios推送测试<br/>
ios token:<br/><input id="token" type="text" name="token" /><br/>
通知标题：<br/><input id="iostitle" type="text" name="iostitle" /><br/>
type:<select id="type"><option value="1">通用</option><option value="2">中行</option><option value="3">演示</option>
<option value="4">通用（iphone-企业）</option>
<option value="5">中行（iphone-企业）</option>
<option value="6">通用（ipad-appstore）</option>
<option value="7">中行（ipad- appstore）</option>
<option value="8">通用（ipad-企业）</option>
<option value="9">中行（ipad-企业）</option>
</select><br/>
data:<br/><textarea id="iosdata" width="800px" rows="10" cols="100" >{"topicId":10,"type":1,"createTime":"2014-09-12 13:38:51","atMe":0}</textarea><br/>
<input type="button" class="sendPush" value="发送推送"/>

<%-- <form action="./tycloud/alarmservicecmd" method="post">
<input type="button" onclick="test()">
<input type="submit">
</form> --%>
<script type="text/javascript" src="<c:url value="/jslib/jquery/jquery.min.js" />"></script>
<script type="text/javascript" src="<c:url value="jslib/easyui1.5/jquery.easyui.min.js" />"></script>
<%--
<script type="text/javascript" src="<c:url value="/jslib/json/json2.js" />"></script>
--%>
<%--
<script type="text/javascript" src="<c:url value="/jslib/jquery-validation/lib/jquery.form.js" />"></script>
--%>
<script type="text/javascript">
var files = new Array();
    $(function() {
        $('.sendApiRequest').bind('click',function(){
        	sendRequest();
        });
        $('.sendPush').bind('click',function(){
        	iosSend();
        });
        $('#appDiv').combobox({
            onSelect:function(reason){
                var div = $(this).combobox('getValue');
                //$(':input').not('select,.combo-text,.combo-value,.sendPush').val('');
                $('#fileDiv').hide();
                clearFile();

                if (div != '') {
                	initMethodCombox(div);	
                } else {
                	$('#methodOperate').combobox('clear');
                	$('#methodOperate').combobox('loadData','{}');
                }
            },
            onLoadSuccess:function(){
            }
        });
        function initMethodCombox(div) {
        	var data;
        	if (div == '0') {
        		
        		data = [{"id":"1","name":"1. 用户登录"},{"id":"2","name":"2. 用户登出"},{"id":"3","name":"3. 密码修改"}/*,
                        {"id":"4","name":"4. 获取报警信息列表"},{"id":"5","name":"5. 获取报警评论列表及处理结果"},
                        {"id":"6","name":"6. 报警回复评论"},{"id":"7","name":"7. 获取指定报警信息的临时群组联系人信息"},
                        {"id":"8","name":"8. 获取备用群组联系人信息"},{"id":"9","name":"9. 添加备用人员到临时群组"},
                        {"id":"10","name":"10. 网点负责人—获取网点布防信息"},{"id":"11","name":"11. 网点负责人—申请延迟布防"},
                        {"id":"12","name":"12. 网点负责人—取消延迟布防"},{"id":"13","name":"13. 中心负责人—获取布防信息列表"},
                        {"id":"14","name":"14. 获取报警类型列表"},{"id":"15","name":"15. 获取指定网点下所有组织机构列表"},
                        {"id":"16","name":"16. 查询报警信息列表"},{"id":"17","name":"17. 根据报警ID查询报警信息"},
                        {"id":"18","name":"18. 提交建议"},{"id":"19","name":"19. 拉取动态信息（拉取时间段服务器端控制）"},
                        {"id":"20","name":"20. 获取广播消息（拉取时间段服务器端控制）"},{"id":"21","name":"21. 获取报警处理结果"},
                        {"id":"22","name":"22. 获取报警评论列表"},{"id":"23","name":"23. 获取指定报警类型、指定网点的群组联系人信息"},
                        {"id":"24","name":"24. 报警回复评论"},{"id":"25","name":"25. 网点负责人—取消延迟布防并获取最新布防信息"},
                        {"id":"26","name":"26.中心负责人—获取时间段内报警数量"},{"id":"27","name":"27.中心负责人—获取报警(分类)"},
                        {"id":"28","name":"28.账号绑定"},{"id":"29","name":"29.账号解除绑定"},
                        {"id":"30","name":"30.获取子组织机构"},{"id":"31","name":"31.获取能查看的网点属性列表"}
                        ,{"id":"32","name":"32.报警读取状态设置"},{"id":"33","name":"33.布防查询"},{"id":"34","name":"34.查询子机构（最后叶节点网点信息）"}
                        ,{"id":"35","name":"35.中心负责人—获取时间段内报警数量和最新报警列表"}
                        ,{"id":"36","name":"36.中心负责人获取最新报警信息列表"},{"id":"37","name":"37.收到推送消息反馈"}
                        ,{"id":"38","name":"38.发送CID到服务器"}
                        ,{"id":"39","name":"39.分页拉取个人报警评论"}*/
                        ];
        	} else if (div == '1') {
                data = [{"id":"1","name":"1. 用户登录及获取相关信息"},
                        {"id":"2","name":"2. 用户登出"},
                        {"id":"3","name":"3. 密码修改"},
                        {"id":"4","name":"4. 获取报警信息列表"},
                        {"id":"5","name":"5. 获取报警处理结果及评论列表"},
                        {"id":"6","name":"6. 报警接警操作"},
                        {"id":"7","name":"7. 报警到达操作"},
                        {"id":"8","name":"8. 报警处置"},
                        {"id":"9","name":"9. 处置完毕"},
                        {"id":"10","name":"10. 根据报警ID查询"},
                        {"id":"11","name":"11. 报警分类时间查询（分页）"},
                        {"id":"12","name":"12. 获取报警类型列表"},
                        {"id":"13","name":"13. 报警处置并且完毕"},
                        {"id":"14","name":"14. 发送推送CID到服务器"}
                        ];
        	} else if (div == '2') {
        		data = [{"id":"1","name":"1. 代理服务器登陆"},
                        {"id":"2","name":"2. 代理服务器登出"},
                        {"id":"3","name":"3. 视频信息登录"},
                        {"id":"4","name":"4. 图片信息登录"},
                        {"id":"5","name":"5. 客户端视频列表获取"},
                        {"id":"6","name":"6. 客户端图片列表获取"},
                        {"id":"7","name":"7. 获取访问地址"}
                        ];
        	}
            $('#methodOperate').combobox({
                data:data,
                valueField : 'id',
                textField : 'name',
                //panelHeight: 'auto',
                onSelect:function(reason){
                    var currentvalue = parseInt($('#methodOperate').combobox("getValue"));
                    var div = $('#appDiv').combobox('getValue');
                    createParamFormat(currentvalue,div);
                    var proCase = $(this).combobox('getValue');
                    if(div=='0'){
                    	$('#reqUrl').val("<%=basePath %>/appServiceCall");
                    	$('#fileDiv').hide();
                        clearFile();
                    }else if (div == '1' && (proCase == '8' || proCase == '13')) {
                        $('#reqUrl').val("<%=basePath %>/spidp/security_alarm/fileupload");
                    	//文件上传
                    	$('#fileDiv').show();
                    }else if (div == '2') {
                    	if (proCase >= 5) {
                        	$('#reqUrl').val("<%=basePath %>/tycloud/cmdservice/connection/client");
                        } else {
                        	$('#reqUrl').val("<%=basePath %>/tycloud/cmdservice/connection/proxy");
                        }
                    	$('#fileDiv').hide();
                        clearFile();
                    } else {
                        $('#fileDiv').hide();
                        clearFile();
                        $('#reqUrl').val("<%=basePath %>/platform/appServiceCall");
                    }
                },
                onLoadSuccess:function(){
                    
                }
            });
        }
        function createParamFormat(val,div){
            var defaultData = "";
            if (div == '0') {
            	initKoalaAlarmParams(val);
            } else if (div == '1'){
            	initSecurityAlarmParams(val);
            } else if (div == '2') {
            	initAlarmMediaParams(val);
            }
        }
        function initKoalaAlarmParams(val){
        	switch(val){
            case 1:
                $("#reqmethod").val("App_Action_Login");
                defaultData = "{\"jsonrpc\": \"2.0\",\"method\": \"App_Action_Login\",\"params\": {\"userName\": \"wsradmin\",\"password\": \"666666\",\"encryptType\":3,\"device\":2,\"deviceToken\":\"dlkdlkd2322\",\"appType\":1,\"versionCode\":\"123456\",\"clientId\":\"\"},\"id\": 1}";
                break;
                
            case 2:
                $("#reqmethod").val("App_Action_Logout");
                defaultData = "{\"jsonrpc\": \"2.0\",\"method\": \"App_Action_Logout\",\"params\": {\"userGuid\": \"A4800B01-69F9-40E7-B041-EF8867AA1DD3\"},\"id\": 2}";
                break;
                
            case 3:
                $("#reqmethod").val("App_Action_PasswordModify");
                defaultData = "{\"jsonrpc\": \"2.0\",\"method\": \"App_Action_PasswordModify\",\"params\": {\"userGuid\": \"A4800B01-69F9-40E7-B041-EF8867AA1DD3\",\"loginName\":\"360121199004040511\",\"oldPassword\":\"admi1\",\"newPassword\":\"123456\"},\"id\": 3}";
                break;
            case 4:
                $("#reqmethod").val("App_Get_AlarmList");
                defaultData = "{\"jsonrpc\": \"2.0\",\"method\": \"App_Get_AlarmList\",\"params\": {\"userGuid\": \"A4800B01-69F9-40E7-B041-EF8867AA1DD3\",\"page\":1,\"count\":10,\"dateType\":\"all\"},\"id\": 3}";
                break;
            case 5:
                $("#reqmethod").val("App_Get_AlarmHandleResultComment");
                defaultData = "{\"jsonrpc\": \"2.0\",\"method\": \"App_Get_AlarmHandleResultComment\",\"params\": {\"userGuid\": \"A4800B01-69F9-40E7-B041-EF8867AA1DD3\",\"alarmId\":16,\"replyId\":0},\"id\": 3}";
                break;
            case 6:
                $("#reqmethod").val("App_Action_ReplyInfo");
                defaultData = "{\"jsonrpc\": \"2.0\",\"method\": \"App_Action_ReplyInfo\",\"params\": {\"userGuid\": \"A4800B01-69F9-40E7-B041-EF8867AA1DD3\",\"alarmId\":16,\"replyId\":2,\"content\":\"员工2，请立刻处理！\"},\"id\": 3}";
                break;
            case 7:
                $("#reqmethod").val("App_Get_TempGroupInfoByAlarmId");
                defaultData = "{\"jsonrpc\": \"2.0\",\"method\": \"App_Get_TempGroupInfoByAlarmId\",\"params\": {\"userGuid\": \"A4800B01-69F9-40E7-B041-EF8867AA1DD3\",\"alarmId\":16},\"id\": 3}";
                break;
            case 8:
                $("#reqmethod").val("App_Get_BenchGroupInfo");
                defaultData = "{\"jsonrpc\": \"2.0\",\"method\": \"App_Get_BenchGroupInfo\",\"params\": {\"userGuid\": \"A4800B01-69F9-40E7-B041-EF8867AA1DD3\",\"alarmCode\":\"110\",\"organizationId\":0},\"id\": 3}";
                break;
            case 9:
                $("#reqmethod").val("App_Action_AddToTempGroup");
                defaultData = "{\"jsonrpc\": \"2.0\",\"method\": \"App_Action_AddToTempGroup\",\"params\": {\"userGuid\": \"A4800B01-69F9-40E7-B041-EF8867AA1DD3\",\"groupId\":28,\"customList\":[5,6]},\"id\": 3}";
                break;
            case 10:
                $("#reqmethod").val("App_Get_BranchDeployInfo");
                defaultData = "{\"jsonrpc\": \"2.0\",\"method\": \"App_Get_BranchDeployInfo\",\"params\": {\"userGuid\": \"A4800B01-69F9-40E7-B041-EF8867AA1DD3\",\"organizationId\":2},\"id\": 3}";
                break;
            case 11:
                $("#reqmethod").val("App_Action_DelayDeploy");
                defaultData = "{\"jsonrpc\": \"2.0\",\"method\": \"App_Action_DelayDeploy\",\"params\": {\"userGuid\": \"A4800B01-69F9-40E7-B041-EF8867AA1DD3\",\"organizationId\":1,\"delayDeployTime\":\"2014-09-08 19:30:01\",\"delayDeployType\":1,\"delayDeployReason\":\"开会\"},\"id\": 3}";
                break;
            case 12:
                $("#reqmethod").val("App_Action_CancelDelayDeploy");
                defaultData = "{\"jsonrpc\": \"2.0\",\"method\": \"App_Action_CancelDelayDeploy\",\"params\": {\"userGuid\": \"A4800B01-69F9-40E7-B041-EF8867AA1DD3\",\"organizationId\":1501},\"id\": 3}";
                break;
            case 13:
                $("#reqmethod").val("App_Get_DeploymentList");
                defaultData = "{\"jsonrpc\": \"2.0\",\"method\": \"App_Get_DeploymentList\",\"params\": {\"userGuid\": \"A4800B01-69F9-40E7-B041-EF8867AA1DD3\"},\"id\": 3}";
                break;
            case 14:
                $("#reqmethod").val("App_Get_AlarmTypeList");
                defaultData = "{\"jsonrpc\": \"2.0\",\"method\": \"App_Get_AlarmTypeList\",\"params\": {\"userGuid\": \"A4800B01-69F9-40E7-B041-EF8867AA1DD3\"},\"id\": 3}";
                break;
            case 15:
                $("#reqmethod").val("App_Get_OrganizationList");
                defaultData = "{\"jsonrpc\": \"2.0\",\"method\": \"App_Get_OrganizationList\",\"params\": {\"userGuid\": \"A4800B01-69F9-40E7-B041-EF8867AA1DD3\",\"organizationId\":2},\"id\": 3}";
                break;
            case 16:
                $("#reqmethod").val("App_Get_Query_AlarmList");
                defaultData = "{\"jsonrpc\": \"2.0\",\"method\": \"App_Get_Query_AlarmList\",\"params\": {\"userGuid\": \"A4800B01-69F9-40E7-B041-EF8867AA1DD3\",\"organizationId\":0,\"startTime\":\"2014-09-08 19:30:01\",\"endTime\":\"2015-11-08 19:30:01\",\"alarmCodeSearch\":[\"CA100\",\"CA200\"],\"page\":1,\"count\":20},\"id\": 3}";
                break;
            case 17:
                $("#reqmethod").val("App_Get_AlarmInfoByAlarmId");
                defaultData = "{\"jsonrpc\": \"2.0\",\"method\": \"App_Get_AlarmInfoByAlarmId\",\"params\": {\"userGuid\": \"A4800B01-69F9-40E7-B041-EF8867AA1DD3\",\"alarmId\":16},\"id\": 3}";
                break;
            case 18:
                $("#reqmethod").val("App_Action_Suggest");
                defaultData = "{\"jsonrpc\": \"2.0\",\"method\": \"App_Action_Suggest\",\"params\": {\"userGuid\": \"A4800B01-69F9-40E7-B041-EF8867AA1DD3\",\"content\":\"此人不错\"},\"id\": 3}";
                break;
            case 19:
                $("#reqmethod").val("App_Get_DynamicInfo");
                defaultData = "{\"jsonrpc\": \"2.0\",\"method\": \"App_Get_DynamicInfo\",\"params\": {\"userGuid\": \"A4800B01-69F9-40E7-B041-EF8867AA1DD3\"},\"id\": 3}";
                break;
            case 20:
                $("#reqmethod").val("App_Get_MessageInfo");
                defaultData = "{\"jsonrpc\": \"2.0\",\"method\": \"App_Get_MessageInfo\",\"params\": {\"userGuid\": \"A4800B01-69F9-40E7-B041-EF8867AA1DD3\",\"lastMessageStamp\":\"2014-11-04 12:00:00\"},\"id\": 3}";
                break;
            case 21:
                $("#reqmethod").val("App_Get_AlarmHandleResult");
                defaultData = "{\"jsonrpc\": \"2.0\",\"method\": \"App_Get_AlarmHandleResult\",\"params\": {\"userGuid\": \"A4800B01-69F9-40E7-B041-EF8867AA1DD3\",\"alarmId\":16},\"id\": 3}";
                break;
            case 22:
                $("#reqmethod").val("App_Get_AlarmComment");
                defaultData = "{\"jsonrpc\": \"2.0\",\"method\": \"App_Get_AlarmComment\",\"params\": {\"userGuid\": \"A4800B01-69F9-40E7-B041-EF8867AA1DD3\",\"alarmId\":16,\"replyId\":0},\"id\": 3}";
                break;
            case 23:
                $("#reqmethod").val("App_Get_TempGroupInfoByAlarmTypeAndOrganization");
                defaultData = "{\"jsonrpc\": \"2.0\",\"method\": \"App_Get_TempGroupInfoByAlarmTypeAndOrganization\",\"params\": {\"userGuid\": \"A4800B01-69F9-40E7-B041-EF8867AA1DD3\",\"alarmCode\":\"CA100\",\"organizationId\":2},\"id\": 3}";
                break;
            case 24:
                $("#reqmethod").val("App_Action_ReplyInfo_Get_AlarmComment");
                defaultData = "{\"jsonrpc\": \"2.0\",\"method\": \"App_Action_ReplyInfo_Get_AlarmComment\",\"params\": {\"userGuid\": \"A4800B01-69F9-40E7-B041-EF8867AA1DD3\",\"alarmId\":16,\"replyId\":2,\"content\":\"请处理！\",\"replyId_add\":18},\"id\": 3}";
                break;
            case 25:
                $("#reqmethod").val("App_Action_CancelDelayDeploy_GetDeployInfo");
                defaultData = "{\"jsonrpc\": \"2.0\",\"method\": \"App_Action_CancelDelayDeploy_GetDeployInfo\",\"params\": {\"userGuid\": \"A4800B01-69F9-40E7-B041-EF8867AA1DD3\",\"organizationId\":2},\"id\": 3}";
                break;
            case 26:
                $("#reqmethod").val("App_Get_AlarmCount");
                defaultData = "{\"jsonrpc\": \"2.0\",\"method\": \"App_Get_AlarmCount\",\"params\": {\"userGuid\": \"A4800B01-69F9-40E7-B041-EF8867AA1DD3\",\"beginTime\":\"2014-12-01 12:23:34\",\"endTime\":\"2014-12-21 12:23:34\",\"alarmList\":[\"CA100\",\"CA200\"]},\"id\": 5}";
                break;
            case 27:
                $("#reqmethod").val("App_Get_Type_AlarmList");
                defaultData = "{\"jsonrpc\": \"2.0\",\"method\": \"App_Get_Type_AlarmList\",\"params\": {\"userGuid\": \"A4800B01-69F9-40E7-B041-EF8867AA1DD3\",\"alarmCode\":\"CA100\",\"beginTime\":\"2014-12-01 12:23:34\",\"endTime\":\"2014-12-21 12:23:34\",\"page\":1,\"count\":10},\"id\": 6}";
                break;
            case 28:
                $("#reqmethod").val("App_Action_Account_Binding");
                defaultData = "{\"jsonrpc\": \"2.0\",\"method\": \"App_Action_Account_Binding\",\"params\": {\"userGuid\": \"A4800B01-69F9-40E7-B041-EF8867AA1DD3\",\"serialNumber\":\"56789090323\",\"encryptType\":0,\"type\":1},\"id\": 6}";
                break;
            case 29:
                $("#reqmethod").val("App_Action_Account_Unbind");
                defaultData = "{\"jsonrpc\": \"2.0\",\"method\": \"App_Action_Account_Unbind\",\"params\": {\"userGuid\": \"A4800B01-69F9-40E7-B041-EF8867AA1DD3\",\"type\":1},\"id\": 6}";
                break;
            case 30:
                $("#reqmethod").val("App_Get_ChildrenOrgDeployInfo");
                defaultData = "{\"jsonrpc\": \"2.0\",\"method\": \"App_Get_ChildrenOrgDeployInfo\",\"params\": {\"userGuid\": \"A4800B01-69F9-40E7-B041-EF8867AA1DD3\",\"organizationId\":100,\"organizationAttributeId\":\"01\"},\"id\": 6}";
                break;
            case 31:
                $("#reqmethod").val("App_Get_AttributeList");
                defaultData = "{\"jsonrpc\": \"2.0\",\"method\": \"App_Get_AttributeList\",\"params\": {\"userGuid\": \"A4800B01-69F9-40E7-B041-EF8867AA1DD3\"},\"id\": 6}";
                break;
            case 32:
                $("#reqmethod").val("App_Action_SetAlarmReadStatus");
                defaultData = "{\"jsonrpc\": \"2.0\",\"method\": \"App_Action_SetAlarmReadStatus\",\"params\": {\"userGuid\": \"A4800B01-69F9-40E7-B041-EF8867AA1DD3\",\"alarmStatusList\":[{\"alarmId\":1821,\"readStatus\":1},{\"alarmId\":1822,\"readStatus\":1}]},\"id\": 6}";
                break;
            case 33:
                $("#reqmethod").val("App_Get_HistoryDeploy");
                defaultData = "{\"jsonrpc\": \"2.0\",\"method\": \"App_Get_HistoryDeploy\",\"params\": {\"userGuid\": \"A4800B01-69F9-40E7-B041-EF8867AA1DD3\",\"dayTime\":\"2014-09-08 19:30:01\",\"organizationId\":100},\"id\": 6}";
                break;
            case 34:
                $("#reqmethod").val("App_Get_SonBranchList");
                defaultData = "{\"jsonrpc\": \"2.0\",\"method\": \"App_Get_SonBranchList\",\"params\": {\"userGuid\": \"A4800B01-69F9-40E7-B041-EF8867AA1DD3\",\"organizationId\":100},\"id\": 6}";
                break;
            case 35:
                $("#reqmethod").val("App_Get_AlarmCountAndNewAlarm");
                defaultData = "{\"jsonrpc\": \"2.0\",\"method\": \"App_Get_AlarmCountAndNewAlarm\",\"params\":{\"userGuid\": \"A4800B01-69F9-40E7-B041-EF8867AA1DD3\",\"beginTime\":\"2014-12-01 12:23:34\",\"endTime\":\"2014-12-21 12:23:34\",\"alarmList\":[\"CA100\",\"CA200\"],\"newAlarmCount\":2},\"id\": 5}";
                break;
            case 36:
                $("#reqmethod").val("App_Get_NewAlarmList");
                defaultData = "{\"jsonrpc\": \"2.0\",\"method\": \"App_Get_NewAlarmList\",\"params\": {\"userGuid\": \"A4800B01-69F9-40E7-B041-EF8867AA1DD3\",\"count\":101},\"id\": 3}";
                break;
            case 37:
                $("#reqmethod").val("App_Action_Msg_Feedback");
                defaultData = "{\"jsonrpc\": \"2.0\",\"method\": \"App_Action_Msg_Feedback\",\"params\": {\"userGuid\": \"A4800B01-69F9-40E7-B041-EF8867AA1DD3\",\"userId\":10121,\"taskId\":\"13erfe-rte8001-38000\"},\"id\": 3}";
                break;
            case 38:
                $("#reqmethod").val("App_Action_Send_ClientId");
                defaultData = "{\"jsonrpc\": \"2.0\",\"method\": \"App_Action_Send_ClientId\",\"params\": {\"userGuid\": \"A4800B01-69F9-40E7-B041-EF8867AA1DD3\",\"userId\":10121,\"clientId\":\"13erfe-rte8001-38000\",\"device\":2},\"id\": 3}";
                break;
            case 39:
                $("#reqmethod").val("App_Get_AlarmComment_PagingList");
                defaultData = "{\"jsonrpc\": \"2.0\",\"method\": \"App_Get_AlarmComment_PagingList\",\"params\": {\"userGuid\": \"A4800B01-69F9-40E7-B041-EF8867AA1DD3\",\"page\":1,\"pageSize\":10},\"id\": 3}";
                break;
                default:
                    alert("还不支持该API，请稍有耐心，敬请期待下回公告，谢谢！");return;
            }
            $("#txtrequestbody").val(defaultData);
        }
        
        function initSecurityAlarmParams(val){
            switch(val){
            case 1:
                $("#reqmethod").val("Ms_Action_Login");
                defaultData = {
                		  "jsonrpc": "2.0",
                		  "method": "Ms_Action_Login",
                		  "params": {
                		    "userName": "14400000009",
                		    "password": "666666",
                		    "encryptType": 0,
                		    "versionCode": "123456",
                		    "device": 1,
                		    "deviceToken": "dlkdlkd2322"
                		  },
                		  "id": 1
                		};
                break;
                
            case 2:
                $("#reqmethod").val("Ms_Action_Logout");
                defaultData = {
                		  "jsonrpc": "2.0",
                		  "method": "Ms_Action_Logout",
                		  "params": {
                		    "userGuid": "A4800B01-69F9-40E7-B041-EF8867AA1DD3"
                		  },
                		  "id": 123
                		};
                break;
            case 3:
                $("#reqmethod").val("Ms_Action_PasswordModify");
                defaultData = {
                		  "jsonrpc": "2.0",
                		  "method": "Ms_Action_PasswordModify",
                		  "params": {
                		    "userGuid": "A4800B01-69F9-40E7-B041-EF8867AA1DD3",
                		    "loginName": "13800138000",
                		    "oldPassword": "ty123456789",
                		    "newPassword": "09876543ty"
                		  },
                		  "id": 123
                		};
                break;
            case 4:
                $("#reqmethod").val("Ms_Get_AlarmList");
                defaultData = {
                		  "jsonrpc": "2.0",
                		  "method": "Ms_Get_AlarmList",
                		  "params": {
                		    "userGuid": "A4800B01-69F9-40E7-B041-EF8867AA1DD3", //用户GUID
                		    "page": 10, //page页码
                		    "count": 20 //拉取该page的数据量
                		  },
                		  "id": 123
                		};
                break;
            case 5:
                $("#reqmethod").val("Ms_Get_AlarmComment");
                defaultData = {
                		  "jsonrpc": "2.0",
                		  "method": "Ms_Get_AlarmComment",
                		  "params": {
                		    "userGuid": "A4800B01-69F9-40E7-B041-EF8867AA1DD3",
                		    "alarmId": 1501,
                		    "replyId": 1
                		  },
                		  "id": -123
                		};
                break;
            case 6:
                $("#reqmethod").val("Ms_Action_Accept");
                defaultData = {
                		  "jsonrpc": "2.0",
                		  "method": "Ms_Action_Accept",
                		  "params": {
                		    "userGuid": "A4800B01-69F9-40E7-B041-EF8867AA1DD3", //用户GUID
                		    "alarmId": 16, //报警id
                		    "gpsTime": "2014-04-25 11:28:00", //gps获取时间
                		    "receiveTime": "2014-04-25 11:28:00", //接警时间
                		    "longt": 25.3365457887, //接警位置经度
                		    "lat": 125.3658545654, //接警位置纬度
                		    "positionError": 210.23, //位置误差米
                		    "addrdesc": "曲阳路近中山北二路"//位置描述
                		  },
                		  "id": 123
                		}
                break;
            case 7:
                $("#reqmethod").val("Ms_Action_Arrive");
                defaultData = {
                          "jsonrpc": "2.0",
                          "method": "Ms_Action_Arrive",
                          "params": {
                            "userGuid": "A4800B01-69F9-40E7-B041-EF8867AA1DD3", //用户GUID
                            "alarmId": 123456, //报警id
                            "gpsTime": "2014-04-25 11:28:00", //gps获取时间
                            "arriveTime": "2014-04-25 11:28:00", //到达时间
                            "longt": 25.3365457887, //到达位置经度
                            "lat": 125.3658545654, //到达位置纬度
                            "positionError": 210.23, //位置误差米
                            "addrdesc": "曲阳路近中山北二路" //位置描述
                          },
                          "id": 123
                        };
                break;
            case 8:
                $("#reqmethod").val("Ms_Action_HandleResult");
                defaultData = {
                          "jsonrpc": "2.0",
                          "method": "Ms_Action_HandleResult",
                          "params": {
                            "userGuid": "A4800B01-69F9-40E7-B041-EF8867AA1DD3",
                            "alarmId": 123,
                            "operateResultType": 1,
                            "alarmDes": "报警处置描述"
                          },
                          "id": -945114
                        };
                break;
            case 9:
                $("#reqmethod").val("Ms_Action_HandleFinish");
                defaultData = {
                          "jsonrpc": "2.0",
                          "method": "Ms_Action_HandleFinish",
                          "params": {
                            "userGuid": "A4800B01-69F9-40E7-B041-EF8867AA1DD3", //用户GUID    
                            "alarmId": 09876543 //报警id
                          },
                          "id": 123
                        };
                break;
            case 10:
                $("#reqmethod").val("Ms_Get_AlarmInfoByAlarmId");
                defaultData = {
                          "jsonrpc": "2.0",
                          "method": "Ms_Get_AlarmInfoByAlarmId",
                          "params": {
                            "userGuid": "A4800B01-69F9-40E7-B041-EF8867AA1DD3", //用户GUID
                            "alarmId": 123 //报警Id（查询条件）
                          },
                          "id": 123
                        };
                break;
            case 11:
                $("#reqmethod").val("Ms_Get_QueryAlarmByType");
                defaultData = {
                          "jsonrpc": "2.0",
                          "method": "Ms_Get_QueryAlarmByType",
                          "params": {
                            "userGuid": "A4800B01-69F9-40E7-B041-EF8867AA1DD3", //用户GUID
                            "operateResultType": 1, //1误报，2实警，3无异常, 0全部
                            "queryDate": "2015-11", //时间
                            "page": 10, //page页码
                            "count": 20 //拉取该page的数据量
                          },
                          "id": 123
                        };
                break;
            case 12:
                $("#reqmethod").val("Ms_Get_AlarmTypeList");
                defaultData = {
                          "jsonrpc": "2.0",
                          "method": "Ms_Get_AlarmTypeList",
                          "params": {
                            "userGuid": "A4800B01-69F9-40E7-B041-EF8867AA1DD3" //用户GUID
                          },
                          "id": 123
                        };
                break;
            case 13:
                $("#reqmethod").val("Ms_Action_HandleResult_Finish");
                defaultData = {
                		  "jsonrpc": "2.0",
                		  "method": "Ms_Action_HandleResult_Finish",
                		  "params": {
                		    "userGuid": "A4800B01-69F9-40E7-B041-EF8867AA1DD3", //用户GUID    
                		    "alarmId": 123,
                		    "operateResultType": 1,
                		    "alarmDes": "报警处置描述"
                		  },
                		  "id": 123
                		};
                break;
            case 14:
                $("#reqmethod").val("Ms_Action_Send_ClientId");
                defaultData = {
                		  "jsonrpc": "2.0",
                		  "method": "Ms_Action_Send_ClientId",
                		  "params": {
                		    "userGuid": "A4800B01-69F9-40E7-B041-EF8867AA1DD3",
                		    "clientId": "13erfe-rte8001-38000",
                		    "device": 1,
                		    "userId": 43441
                		  },
                		  "id": 123
                		}
                break;
            default:
                alert("还不支持该API，请稍有耐心，敬请期待下回公告，谢谢！");return;
            }
            
            var outputStr = JSON.stringify(defaultData, undefined, 4);
            $("#txtrequestbody").val(outputStr);
        }

        function initAlarmMediaParams(val){
            switch(val){
            case 1:
                $("#reqmethod").val("ME_ACTION_LOGIN");
                defaultData = {
                		  "jsonrpc": "2.0",
                		  "method": "ME_ACTION_LOGIN",
                		  "params": {
                		    "proxyId": "ZYMediaProxy", //代理登录ID
                		    "password": "666666", //密码
                		    "encryptType": 0 //密码加密类型，0表示明文，1表示MD5，2表示SHA1
                		  },
                		  "id": 1 //创建请求时发送方自己定义的标识符
                		};
                break;
            case 2:
                $("#reqmethod").val("ME_ACTION_LOGOUT");
                defaultData = {
                		  "jsonrpc": "2.0",
                		  "method": "ME_ACTION_LOGOUT",
                		  "params": {
                		"proxyGuid": "A4800B01-69F9-40E7-B041-EF8867AA1DD3" //代理识别GUID
                		},
                		  "id": 1 //创建请求时发送方自己定义的标识符
                		};
                break;
            case 3:
                $("#reqmethod").val("ME_ACTION_UPLOADVIDEO");
                defaultData = {
                		  "jsonrpc": "2.0",
                		  "method": "ME_ACTION_UPLOADVIDEO",
                		  "params": {
                		    "proxyGuid": "A4800B01-69F9-40E7-B041-EF8867AA1DD3", //代理识别GUID
                		    "videos": [{
                		      "alarmGuid": "ZY20151227000012123", //对应报警的GUID
                		      "fileGuid":"ZY20151227000012121",
                		      "filePath": "/upload/20151227 ", //指定FTP上传目录作为根目录填写
                		      "fileName": "ZY20151227000012121.mp4",
                		      "fileSize": 115158098, //字节（115158098/1024/1024）MB
                		      "startTime": "2015-12-27 00:00:12", //视频的开始时间
                		      "endTime": "2015-12-27 00:00:42", //视频的结束时间
                		      "channel": "中行XXXATM第一视频源通道" //视频源的通道名称
                		    }, {
                  		      "alarmGuid": "ZY20151227000012123", //对应报警的GUID
                		      "fileGuid":"ZY20151227000012121",
                		      "filePath": "/upload/20151227 ", //指定FTP上传目录作为根目录填写
                		      "fileName": "ZY20151227000012121.mp4",
                		      "fileSize": 115158098, //字节（115158098/1024/1024）MB
                		      "startTime": "2015-12-27 00:00:12", //视频的开始时间
                		      "endTime": "2015-12-27 00:00:42", //视频的结束时间
                		      "channel": "中行XXXATM第一视频源通道" //视频源的通道名称
                		    }]
                		  },
                		  "id": 1 //创建请求时发送方自己定义的标识符
                		};
                break;
            case 4:
                $("#reqmethod").val("ME_ACTION_UPLOADIMG");
                defaultData = {
                		  "jsonrpc": "2.0",
                		  "method": "ME_ACTION_UPLOADIMG",
                		  "params": {
                		    "proxyGuid": "A4800B01-69F9-40E7-B041-EF8867AA1DD3", //代理识别GUID
                		    "images": [{
                		      "alarmGuid": "ZY20151227000012123", //对应报警的GUID
                		      "filePath": "/upload/20151227 ", //指定FTP上传目录作为根目录填写
                		      "fileName": "ZY20151227000012121.jpg",
                		      "fileSize": 1024, //字节
                		      "createTime": "2015-12-27 00:00:12", //图片生成时间
                		      "channel": "中行XXXATM第一视频源通道" //图片生成源的通道名称
                		    }, {
                		      "alarmGuid": "ZY20151227000012121", //对应报警的GUID
                		      "filePath": "/upload/20151227 ", //指定FTP上传目录作为根目录填写
                		      "fileName": "ZY20151227000012122.jpg",
                		      "fileSize": 1024, //字节
                		      "createTime": "2015-12-27 00:00:12", //图片生成时间
                		      "channel": "中行XXXATM第一视频源通道" //图片生成源的通道名称
                		    }]
                		  },
                		  "id": 1 //创建请求时发送方自己定义的标识符
                		};
                break;
            case 5:
                $("#reqmethod").val("ME_ACTION_GETVIDEOLIST");
                defaultData = {
                		  "jsonrpc": "2.0",
                		  "method": "ME_ACTION_GETVIDEOLIST",
                		  "params": {
                			  "userGuid": "A4800B01-69F9-40E7-B041-EF8867AA1DD3",
                    		  "thumbnailSpec": 200,
                			  "mediaCondition": {
                    		    "alarmId": 1501,
                    		    "page":0,
                    		    "count":10,
                    		    "startTime": "2015-08-12 00:00:00",
                    		    "endTime": "2016-02-12 00:00:00"
                			  }
                		  },
                		  "id": 123
                		};
                break;
            case 6:
                $("#reqmethod").val("ME_ACTION_GETIMGLIST");
                defaultData = {
              		  "jsonrpc": "2.0",
            		  "method": "ME_ACTION_GETIMGLIST",
            		  "params": {
            			  "userGuid": "A4800B01-69F9-40E7-B041-EF8867AA1DD3",
            			  "thumbnailSpec": 160,
            			  "mediaCondition": {
                		    "alarmId": 17,
                		    "page":0,
                		    "count":10,
                		    "startTime": "2015-08-12 00:00:00",
                		    "endTime": "2016-02-12 00:00:00"
            			  }
            		  },
            		  "id": 123
            		};
                break;
            case 7:
                $("#reqmethod").val("ME_ACTION_GETACCESSURL");
                defaultData = {
                		  "jsonrpc": "2.0",
                		  "method": "ME_ACTION_GETACCESSURL",
                		  "params": {
                		    "userGuid": "A4800B01-69F9-40E7-B041-EF8867AA1DD3", //用户GUID
                		    "alarmId": 16, //报警id
                		    "device": 1,
                		    "accesType": 1
                		  },
                		  "id": 123
                		}
                break;
              //TODO----end
            default:
                alert("还不支持该API，请稍有耐心，敬请期待下回公告，谢谢！");return;
            }
            
            var outputStr = JSON.stringify(defaultData, undefined, 4);
            $("#txtrequestbody").val(outputStr);
        }
        
        function sendRequest(){
            var requestBody = '';
            $("#txtresponsebody").val('');
            //获取区分
            var div = $('#appDiv').combobox('getValue');
            var proCase = $('#methodOperate').combobox('getValue');
            var url = $('#reqUrl').val();
            if($("#txtrequestbody").val() == ""){
                alert("请输入请求体。");
                return;
            } else {
            	var jsonStr = $("#txtrequestbody").val();
            	try {
            		JSON.parse(jsonStr);
            		requestBody = jsonStr;
            	} catch (e) {
            		alert("该请求内容不是json格式。请检查后重新输入。");
            		return;
            	}
            }
            if (div == '1' && (proCase == '8' || proCase == '13')) {
            	$('#uploadProgress').progressbar('setValue', 0);
                //附件上传
                var formData = new FormData();
                if (files.length > 0) formData = new FormData($('#fileForm')[0]);
                formData.append("params",requestBody);
                url:url
                $.ajax({
                    url:url,
                    type: 'post',
                    dataType:"json",
                    // Form数据
                    data: formData,
                    processData: false,  // 告诉jQuery不要去处理发送的数据
                    contentType: false,   // 告诉jQuery不要去设置Content-Type请求头
                    xhr: function() {  // custom xhr
                        myXhr = $.ajaxSettings.xhr();
                        if(myXhr.upload){ // check if upload property exists
                            myXhr.upload.addEventListener('progress',progressHandlingFunction, false); // for handling the progress of the upload
                        }
                        return myXhr;
                    },
                    success: function aa(data) {  
                        $("#txtresponsebody").val(JSON.stringify(data, undefined, 4));    
                    },
                    error : function(XMLHttpRequest, textStatus, errorThrown) {
                       alert("err...");
                       alert(textStatus);
                       alert(errorThrown);
                       alert(XMLHttpRequest);
                    }
                });
            } else {
                $.ajax({
                    type:"post",  
                    contentType : "application/json",
                    processData : false,
                    url:url,
                    dataType:"json",  
                    data : requestBody,
                    success: function aa(data) {  
                         // $("#txtresponsebody").text(JSON.stringify(data));
                         $("#txtresponsebody").val(JSON.stringify(data, undefined, 4));    
                         //console.log(data);
                    },
                    error : function(XMLHttpRequest, textStatus, errorThrown) {
                        alert("err...");
                        alert(textStatus);
                        alert(errorThrown);
                        alert(XMLHttpRequest);
                    }
                });
            }
        }
        
        function iosSend(){
            
            var type=$("#type").val();
            
            var token=$("#token").val();
            if(token==""){
                alert("token不能为空")
                return false;
            }
            var data=$("#iosdata").val();
            var title=$("#iostitle").val();
            alert(data)
            $.ajax({  
                type:"post",  
                url:"<%=basePath %>/tycloud/alarmservicecmd/isoSend",
                data:{token:token,type:type,data:data,title:title},
                success: function (data) {  
                  if(data.code==0){
                      alert("推送成功");
                  }else{
                      alert("推送失败");
                  }
                }
            });
        }
       
        function progressHandlingFunction(e){
            if(e.lengthComputable){
            	$('#uploadProgress').progressbar('setValue', parseInt(e.loaded / event.total * 100));
            }
        }
        
        function clearFile() {
            $(':file').each(function(i,item){
                var file = $(this);
                file.after(file.clone().val("")); 
                file.remove(); 
                $('#uploadProgress').progressbar('setValue', 0);
            });
            files = new Array();
        }
        
        $('.progressbar-value').find('.progressbar-text').css('background','#2196F3');
    });
    function setFiles(obj) {
        var file = obj.files[0];
        name = file.name;
        size = file.size;
        type = file.type;
        files.push(file);
    }


</script>

</body>
</html>